#!/bin/sh

if [ -f /etc/os-release ]
then
   awk -F'=' '$1=="PRETTY_NAME" {gsub("\"",""); print $2}' /etc/os-release
   exit 0
fi

if [ -f /etc/issue ]
then
    sed -e 's/\\n.\\l//' /etc/issue | tr -s '\n' '\n' | dd bs=100 count=1 2>/dev/null
    exit 0
fi

if [ -x /usr/bin/lsb_release ]
then
    /usr/bin/lsb_release -d
    exit 0
fi

if [ -f /etc/debian_version ]
then
    cat /etc/debian_version
    exit 0
fi

SHELL=$(readlink /proc/$$/exe)

if [ "$SHELL" != "${SHELL%busybox*}" ]
then
    echo "busybox system"
    exit 0
fi

echo 'Unsupported distro: cannot determine build version'
